/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-01-19
 * Time: 21:46
 */
import java.util.List;
import java.util.ArrayList;


public class Shop {
    private List<Product>products;
    private double revenue;
    public Shop() {
        products = new ArrayList<>();
        revenue = 0.0;
    }
    public void add(Product item) {
        products.add(item);
    }
    public void viewCatalog() {
        if(products.isEmpty()) {
            System.out.println("leer!");
        }else {
            for(Product product : products) {

                System.out.println(product.getDetails());
            }

        }
    }
    public Product kaufen(int number,String name) {
        for(Product product : products) {
            if(name==product.getBezeichnung()) {
                if(number<=product.getLagerbestand()) {
                    int m = product.getLagerbestand();
                    m-=number;
                    this.revenue+= product.getPreis();
                    System.out.println("Produkt gekauft:"+product.getBezeichnung());
                }else {
                    System.out.println("Das Produkt ist nicht auf Lager;");
                    return null;
                }
            }
        }
        return null;
    }

    public double getrevenue() {
        return this.revenue;
    }
}
